/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.ex;

import org.jsoup.Jsoup;

import javax.swing.*;
import java.io.IOException;
import java.util.regex.Pattern;

/**
 * <p>Project: javase - Ex4
 * <p>Powered by webrx On 2021-12-07 19:04:04
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex4 {
    public static void main(String[] args) throws IOException {
        //mi title
        //https://cn.bing.com/dict/search?q=china&qs=n&form=Z9LH5&sp=-1&pq=china&sc=4-5&sk=&cvid=76FA3245C2334DE2AC960AEA08B07ACB
        var w = JOptionPane.showInputDialog("请输入词汇");
        var u = "https://cn.bing.com/dict/search?q=" + w;
        var t = Jsoup.connect(u).get().select("span[class=def b_regtxt]").get(0).text();
        JOptionPane.showMessageDialog(null, String.format("%s:%s%n", w, t));

        //开发词典软件
        //2022 年
        //16 - 10 - 5 10 10万
        //var p = Pattern.compile("<title>(.+)</title>", Pattern.MULTILINE);
        //var m = p.matcher(t.toString().replace("\n", ""));
        //while (m.find()) {
        //    System.out.println(m.group(1).trim());
        //}
    }
}
